home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / xw2.000 / xw2 / xw / csource / makemfx / testmfx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-22  |  9.1 KB  |  188 lines

  1. /*  XbW MetaFile eXchange (Interface to Applications): XBMFX  */
  2.  
  3. #ifdef thestruct
  4. #undef thestruct
  5. #endif
  6. #define thestruct tst
  7.  
  8. int WriteMFXGroup_tst(char*filename, char*dataset, char *mode){
  9.   if (filename == NULL) { filename = "tst.mfx"; } 
  10.   if (dataset == NULL) { dataset = "tst"; }
  11.   if (mode == NULL) { mode = "w"; }
  12.   if (XbWMFX_WriteSet(filename,dataset,mode)) {
  13.     return(1);
  14.     }
  15. XbWMFX_PutInteger(&thestruct.einsa,"einsa");
  16. XbWMFX_PutDouble(&thestruct.zweia,"zweia");
  17. XbWMFX_PutInteger(&thestruct.dreia,"dreia");
  18. XbWMFX_PutString(thestruct.viera,"viera");
  19. XbWMFX_PutInteger(&thestruct.einsb[0],"einsb[0]");
  20. XbWMFX_PutInteger(&thestruct.einsb[1],"einsb[1]");
  21. XbWMFX_PutInteger(&thestruct.einsb[2],"einsb[2]");
  22. XbWMFX_PutDouble(&thestruct.zweib[0],"zweib[0]");
  23. XbWMFX_PutDouble(&thestruct.zweib[1],"zweib[1]");
  24. XbWMFX_PutInteger(&thestruct.dreib[0],"dreib[0]");
  25. XbWMFX_PutInteger(&thestruct.dreib[1],"dreib[1]");
  26. XbWMFX_PutString(&thestruct.vierb[0][0],"vierb[0]");
  27. XbWMFX_PutString(&thestruct.vierb[1][0],"vierb[1]");
  28. XbWMFX_PutString(&thestruct.vierb[2][0],"vierb[2]");
  29. XbWMFX_PutString(&thestruct.vierb[3][0],"vierb[3]");
  30. XbWMFX_PutString(&thestruct.vierb[4][0],"vierb[4]");
  31. XbWMFX_PutString(&thestruct.vierb[5][0],"vierb[5]");
  32. XbWMFX_PutString(&thestruct.vierb[6][0],"vierb[6]");
  33. XbWMFX_PutString(&thestruct.vierb[7][0],"vierb[7]");
  34. XbWMFX_PutString(&thestruct.vierb[8][0],"vierb[8]");
  35. XbWMFX_PutString(&thestruct.vierb[9][0],"vierb[9]");
  36. XbWMFX_PutString(&thestruct.vierb[10][0],"vierb[10]");
  37. XbWMFX_PutString(&thestruct.vierb[11][0],"vierb[11]");
  38. XbWMFX_PutString(&thestruct.vierb[12][0],"vierb[12]");
  39. XbWMFX_PutString(&thestruct.vierb[13][0],"vierb[13]");
  40. XbWMFX_PutString(&thestruct.vierb[14][0],"vierb[14]");
  41. XbWMFX_PutString(&thestruct.vierb[15][0],"vierb[15]");
  42. XbWMFX_PutString(&thestruct.vierb[16][0],"vierb[16]");
  43. XbWMFX_PutString(&thestruct.vierb[17][0],"vierb[17]");
  44. XbWMFX_PutString(&thestruct.vierb[18][0],"vierb[18]");
  45. XbWMFX_PutString(&thestruct.vierb[19][0],"vierb[19]");
  46. XbWMFX_PutString(&thestruct.vierb[20][0],"vierb[20]");
  47. XbWMFX_PutString(&thestruct.vierb[21][0],"vierb[21]");
  48. XbWMFX_PutString(&thestruct.vierb[22][0],"vierb[22]");
  49. XbWMFX_PutString(&thestruct.vierb[23][0],"vierb[23]");
  50. XbWMFX_PutString(&thestruct.vierb[24][0],"vierb[24]");
  51. XbWMFX_PutString(&thestruct.vierb[25][0],"vierb[25]");
  52. XbWMFX_PutString(&thestruct.vierb[26][0],"vierb[26]");
  53. XbWMFX_PutString(&thestruct.vierb[27][0],"vierb[27]");
  54. XbWMFX_PutString(&thestruct.vierb[28][0],"vierb[28]");
  55. XbWMFX_PutString(&thestruct.vierb[29][0],"vierb[29]");
  56. XbWMFX_PutString(&thestruct.vierb[30][0],"vierb[30]");
  57. XbWMFX_PutString(&thestruct.vierb[31][0],"vierb[31]");
  58. XbWMFX_PutString(&thestruct.vierb[32][0],"vierb[32]");
  59. XbWMFX_PutInteger(&thestruct.einsc[0][0],"einsc[0][0]");
  60. XbWMFX_PutInteger(&thestruct.einsc[0][1],"einsc[0][1]");
  61. XbWMFX_PutInteger(&thestruct.einsc[1][0],"einsc[1][0]");
  62. XbWMFX_PutInteger(&thestruct.einsc[1][1],"einsc[1][1]");
  63. XbWMFX_PutDouble(&thestruct.zweic[0][0],"zweic[0][0]");
  64. XbWMFX_PutDouble(&thestruct.zweic[0][1],"zweic[0][1]");
  65. XbWMFX_PutDouble(&thestruct.zweic[1][0],"zweic[1][0]");
  66. XbWMFX_PutDouble(&thestruct.zweic[1][1],"zweic[1][1]");
  67. XbWMFX_PutInteger(&thestruct.dreic[0][0],"dreic[0][0]");
  68. XbWMFX_PutInteger(&thestruct.dreic[0][1],"dreic[0][1]");
  69. XbWMFX_PutInteger(&thestruct.dreic[1][0],"dreic[1][0]");
  70. XbWMFX_PutInteger(&thestruct.dreic[1][1],"dreic[1][1]");
  71. XbWMFX_PutInteger(&thestruct.einsd[0][0][0],"einsd[0][0][0]");
  72. XbWMFX_PutInteger(&thestruct.einsd[0][0][1],"einsd[0][0][1]");
  73. XbWMFX_PutInteger(&thestruct.einsd[1][0][0],"einsd[1][0][0]");
  74. XbWMFX_PutInteger(&thestruct.einsd[1][0][1],"einsd[1][0][1]");
  75. XbWMFX_PutDouble(&thestruct.zweid[0][0][0],"zweid[0][0][0]");
  76. XbWMFX_PutDouble(&thestruct.zweid[0][0][1],"zweid[0][0][1]");
  77. XbWMFX_PutDouble(&thestruct.zweid[1][0][0],"zweid[1][0][0]");
  78. XbWMFX_PutDouble(&thestruct.zweid[1][0][1],"zweid[1][0][1]");
  79. XbWMFX_PutInteger(&thestruct.dreid[0][0][0],"dreid[0][0][0]");
  80. XbWMFX_PutInteger(&thestruct.dreid[0][0][1],"dreid[0][0][1]");
  81. XbWMFX_PutInteger(&thestruct.dreid[1][0][0],"dreid[1][0][0]");
  82. XbWMFX_PutInteger(&thestruct.dreid[1][0][1],"dreid[1][0][1]");
  83.   XbWMFX_WriteEnd();
  84.   XbWMFX_CloseSet();
  85.   return(0);
  86.   }
  87.  
  88. int ReadMFXGroup_tst(char*filename, char*dataset){
  89.   if (filename == NULL) { filename = "tst.mfx"; } 
  90.   if (dataset == NULL) { dataset = "tst"; }
  91.   if (XbWMFX_ReadSet(filename,dataset)) {
  92.     puts("ERR on opening MFX file; I will now try to append");
  93.     ropenerr:;
  94.     printf("a working MFX Group %s to the end of file %s...\n",dataset,filename);
  95.     if (!WriteMFXGroup_tst(filename,dataset,"a")){
  96.       puts("...done. Exiting with error code.");
  97.       printf("The end of file %s should now be readable. Please check its contents!\n",filename);
  98.       printf("If %s did not exist until now, don't get crazy :)\n",filename);
  99.       return(1);
  100.       }
  101.     else {
  102.       puts("...did not work. Exiting with error code.");
  103.       printf("I must now overwrite your file %s, sorry. Please check its contents!\n",filename);
  104.       WriteMFXGroup_tst(filename,dataset,"w");
  105.       printf("If %s did not exist until now, don't get crazy :)\n",filename);
  106.       return(1);
  107.       }
  108.     }
  109. if(XbWMFX_GetInteger(&thestruct.einsa)){goto error;}
  110. if(XbWMFX_GetDouble(&thestruct.zweia)){goto error;}
  111. if(XbWMFX_GetShort(&thestruct.dreia)){goto error;}
  112. if(XbWMFX_GetString(thestruct.viera)){goto error;}
  113. if(XbWMFX_GetInteger(&thestruct.einsb[0])){goto error;}
  114. if(XbWMFX_GetInteger(&thestruct.einsb[1])){goto error;}
  115. if(XbWMFX_GetInteger(&thestruct.einsb[2])){goto error;}
  116. if(XbWMFX_GetDouble(&thestruct.zweib[0])){goto error;}
  117. if(XbWMFX_GetDouble(&thestruct.zweib[1])){goto error;}
  118. if(XbWMFX_GetShort(&thestruct.dreib[0])){goto error;}
  119. if(XbWMFX_GetShort(&thestruct.dreib[1])){goto error;}
  120. if(XbWMFX_GetString(&thestruct.vierb[0][0])){goto error;}
  121. if(XbWMFX_GetString(&thestruct.vierb[1][0])){goto error;}
  122. if(XbWMFX_GetString(&thestruct.vierb[2][0])){goto error;}
  123. if(XbWMFX_GetString(&thestruct.vierb[3][0])){goto error;}
  124. if(XbWMFX_GetString(&thestruct.vierb[4][0])){goto error;}
  125. if(XbWMFX_GetString(&thestruct.vierb[5][0])){goto error;}
  126. if(XbWMFX_GetString(&thestruct.vierb[6][0])){goto error;}
  127. if(XbWMFX_GetString(&thestruct.vierb[7][0])){goto error;}
  128. if(XbWMFX_GetString(&thestruct.vierb[8][0])){goto error;}
  129. if(XbWMFX_GetString(&thestruct.vierb[9][0])){goto error;}
  130. if(XbWMFX_GetString(&thestruct.vierb[10][0])){goto error;}
  131. if(XbWMFX_GetString(&thestruct.vierb[11][0])){goto error;}
  132. if(XbWMFX_GetString(&thestruct.vierb[12][0])){goto error;}
  133. if(XbWMFX_GetString(&thestruct.vierb[13][0])){goto error;}
  134. if(XbWMFX_GetString(&thestruct.vierb[14][0])){goto error;}
  135. if(XbWMFX_GetString(&thestruct.vierb[15][0])){goto error;}
  136. if(XbWMFX_GetString(&thestruct.vierb[16][0])){goto error;}
  137. if(XbWMFX_GetString(&thestruct.vierb[17][0])){goto error;}
  138. if(XbWMFX_GetString(&thestruct.vierb[18][0])){goto error;}
  139. if(XbWMFX_GetString(&thestruct.vierb[19][0])){goto error;}
  140. if(XbWMFX_GetString(&thestruct.vierb[20][0])){goto error;}
  141. if(XbWMFX_GetString(&thestruct.vierb[21][0])){goto error;}
  142. if(XbWMFX_GetString(&thestruct.vierb[22][0])){goto error;}
  143. if(XbWMFX_GetString(&thestruct.vierb[23][0])){goto error;}
  144. if(XbWMFX_GetString(&thestruct.vierb[24][0])){goto error;}
  145. if(XbWMFX_GetString(&thestruct.vierb[25][0])){goto error;}
  146. if(XbWMFX_GetString(&thestruct.vierb[26][0])){goto error;}
  147. if(XbWMFX_GetString(&thestruct.vierb[27][0])){goto error;}
  148. if(XbWMFX_GetString(&thestruct.vierb[28][0])){goto error;}
  149. if(XbWMFX_GetString(&thestruct.vierb[29][0])){goto error;}
  150. if(XbWMFX_GetString(&thestruct.vierb[30][0])){goto error;}
  151. if(XbWMFX_GetString(&thestruct.vierb[31][0])){goto error;}
  152. if(XbWMFX_GetString(&thestruct.vierb[32][0])){goto error;}
  153. if(XbWMFX_GetInteger(&thestruct.einsc[0][0])){goto error;}
  154. if(XbWMFX_GetInteger(&thestruct.einsc[0][1])){goto error;}
  155. if(XbWMFX_GetInteger(&thestruct.einsc[1][0])){goto error;}
  156. if(XbWMFX_GetInteger(&thestruct.einsc[1][1])){goto error;}
  157. if(XbWMFX_GetDouble(&thestruct.zweic[0][0])){goto error;}
  158. if(XbWMFX_GetDouble(&thestruct.zweic[0][1])){goto error;}
  159. if(XbWMFX_GetDouble(&thestruct.zweic[1][0])){goto error;}
  160. if(XbWMFX_GetDouble(&thestruct.zweic[1][1])){goto error;}
  161. if(XbWMFX_GetShort(&thestruct.dreic[0][0])){goto error;}
  162. if(XbWMFX_GetShort(&thestruct.dreic[0][1])){goto error;}
  163. if(XbWMFX_GetShort(&thestruct.dreic[1][0])){goto error;}
  164. if(XbWMFX_GetShort(&thestruct.dreic[1][1])){goto error;}
  165. if(XbWMFX_GetInteger(&thestruct.einsd[0][0][0])){goto error;}
  166. if(XbWMFX_GetInteger(&thestruct.einsd[0][0][1])){goto error;}
  167. if(XbWMFX_GetInteger(&thestruct.einsd[1][0][0])){goto error;}
  168. if(XbWMFX_GetInteger(&thestruct.einsd[1][0][1])){goto error;}
  169. if(XbWMFX_GetDouble(&thestruct.zweid[0][0][0])){goto error;}
  170. if(XbWMFX_GetDouble(&thestruct.zweid[0][0][1])){goto error;}
  171. if(XbWMFX_GetDouble(&thestruct.zweid[1][0][0])){goto error;}
  172. if(XbWMFX_GetDouble(&thestruct.zweid[1][0][1])){goto error;}
  173. if(XbWMFX_GetShort(&thestruct.dreid[0][0][0])){goto error;}
  174. if(XbWMFX_GetShort(&thestruct.dreid[0][0][1])){goto error;}
  175. if(XbWMFX_GetShort(&thestruct.dreid[1][0][0])){goto error;}
  176. if(XbWMFX_GetShort(&thestruct.dreid[1][0][1])){goto error;}
  177.   XbWMFX_CloseSet();
  178.   return(0);
  179. error:;
  180.   printf("Error while reading MFX Group tst\n");  XbWMFX_CloseSet();
  181.   puts("I will now try to append");
  182.   goto ropenerr;
  183.   }
  184.  
  185.  
  186.  
  187. #undef thestruct
  188.